import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { TechnicianCommissionExtApi } from '#/api/spa/technicians/commissionext';

import { DICT_SPA_TYPE } from '#/utils/dictSpa';
import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'commissionRecordId',
      label: '提成记录ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入提成记录ID',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师ID',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'roomNumber',
      label: '房间号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入房间号',
      },
    },
    {
      fieldName: 'serviceDuration',
      label: '服务时长(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'qualityScore',
      label: '质量评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入质量评分',
      },
    },
    {
      fieldName: 'customerFeedback',
      label: '客户反馈',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户反馈',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'commissionRecordId',
      label: '提成记录ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入提成记录ID',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师ID',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'roomNumber',
      label: '房间号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入房间号',
      },
    },
    {
      fieldName: 'serviceDuration',
      label: '服务时长(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'qualityScore',
      label: '质量评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入质量评分',
      },
    },
    {
      fieldName: 'customerFeedback',
      label: '客户反馈',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户反馈',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<TechnicianCommissionExtApi.TechnicianCommissionExt>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,
    },
    {
      field: 'commissionRecordId',
      title: '提成记录ID',
      minWidth: 120,
    },
    {
      field: 'technicianId',
      title: '技师ID',
      minWidth: 120,
    },
    {
      field: 'serviceId',
      title: '服务ID',
      minWidth: 120,
    },
    {
      field: 'roomId',
      title: '房间ID',
      minWidth: 120,
    },
    {
      field: 'roomNumber',
      title: '房间号',
      minWidth: 120,
    },
    {
      field: 'serviceDuration',
      title: '服务时长(分钟)',
      minWidth: 120,
    },
    {
      field: 'customerId',
      title: '客户ID',
      minWidth: 120,
    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 120,
    },
    {
      field: 'qualityScore',
      title: '质量评分',
      minWidth: 120,
    },
    {
      field: 'customerFeedback',
      title: '客户反馈',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
